public class User {
    private String account;
    private String password;
    private String email;

    // 构造对象(账号与密码必填，邮箱可以选填)
    public User(String account, String password, String email) {
        this.account = account;
        this.password = password;
        this.email = email;
    }

    // 为了让邮箱可选填，可提供一个只有账号和密码的构造函数
    public User(String account, String password) {
        this(account, password, "");
    }

    // 获取账号
    public String getAccount() {
        return account;
    }

    // 设置账号
    public void setAccount(String account) {
        this.account = account;
    }

    // 获取密码
    public String getPassword() {
        return password;
    }

    // 设置密码
    public void setPassword(String password) {
        this.password = password;
    }

    // 获取邮箱
    public String getEmail() {
        return email;
    }

    // 设置邮箱
    public void setEmail(String email) {
        this.email = email;
    }

    // 用户信息展示
    public void UserInfo() {
        System.out.println("账号: " + account);
        System.out.println("密码: " + password);
        if (email != null && !email.isEmpty()) {
            System.out.println("邮箱: " + email);
        } else {
            System.out.println("邮箱: 无");
        }
    }

    public static void main(String[] args) {
        // 创建2个User类对象(一个填邮箱，一个不填邮箱)
        User user1 = new User("小红123", "xiaohong", "hong@qq.com");
        User user2 = new User("小绿123", "xiaolv");

        // 展示用户信息
        System.out.println("user1:");
        user1.UserInfo();

        System.out.println("user2:");
        user2.UserInfo();
    }
}